/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-05
 * Time: 12:34
 */
public class Test {
    public int  size(){
        ListNode cur=head;
        int count=0;
        while (cur!=null){
            count++;
            cur=cur.next;
        }
        return count;
    }
    public void addFirst(int data){
        ListNode node =new ListNode (data);
        ListNode cur=this.head;
        if(this.head==null){
            this.head=node;
        }else{
            while(cur.next!=null){
                cur=cur.next;}
            cur.next=node;

            }

        }

    public void add(int pos,int data) {
        ListNode cur=this.head;
        ListNode node =new ListNode(data);

        int count = 0;
        while(count !=pos-1){
            count++;
            cur=cur.next;

        }
        node.next=cur.next;
        cur.next=node;

    }

    public static void main(String[] args) {
    }
}
